<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单详情</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #f8f9fa;
            color: #333;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* 上层样式 - 顶部导航栏 */
        .top-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 15px 30px;
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            box-shadow: 0 2px 10px rgba(0,0,0,0.15);
            position: sticky;
            top: 0;
            z-index: 100;
            color: white;
        }

        .back-btn {
            background-color: rgba(255,255,255,0.2);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
            border: 1px solid rgba(255,255,255,0.3);
        }

        .back-btn:hover {
            background-color: rgba(255,255,255,0.3);
            transform: translateY(-2px);
        }

        .page-title {
            font-size: 24px;
            font-weight: 700;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
            font-size: 18px;
            font-weight: 500;
        }

        .user-name {
            background-color: rgba(255,255,255,0.2);
            padding: 8px 15px;
            border-radius: 30px;
            border: 1px solid rgba(255,255,255,0.3);
        }

        /* 内容区域样式 */
        .content-container {
            flex: 1;
            padding: 30px;
            max-width: 1200px;
            width: 100%;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
            gap: 30px;
        }

        .order-card {
            background-color: #ffffff;
            border-radius: 16px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.05);
            overflow: hidden;
            padding: 30px;
        }

        .order-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 25px;
            padding-bottom: 20px;
            border-bottom: 1px solid #f0f4f8;
        }

        .order-info {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .info-row {
            display: flex;
            align-items: center;
        }

        .info-label {
            width: 100px;
            color: #7a7e8c;
            font-weight: 500;
        }

        .info-value {
            font-weight: 600;
            color: #2c3e50;
        }

        .order-status {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background-color: #f0f7ff;
            padding: 15px 25px;
            border-radius: 12px;
            min-width: 150px;
        }

        .status-text {
            font-size: 18px;
            font-weight: 700;
            color: #4a6cf7;
        }

        /* 状态流程样式 */
        .status-flow {
            display: flex;
            justify-content: space-between;
            position: relative;
            margin: 40px 0;
            padding: 0 20px;
        }

        .status-flow::before {
            content: '';
            position: absolute;
            top: 30px;
            left: 0;
            right: 0;
            height: 4px;
            background-color: #e0e7ff;
            z-index: 1;
        }

        .status-step {
            display: flex;
            flex-direction: column;
            align-items: center;
            z-index: 2;
            width: 25%;
        }

        .step-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: #f0f4f8;
            margin-bottom: 15px;
            font-size: 24px;
            color: #7a7e8c;
            position: relative;
            border: 3px solid #e0e7ff;
            transition: all 0.3s ease;
        }

        .step-icon.active {
            background-color: #4a6cf7;
            color: white;
            border-color: #3a5ce0;
            transform: scale(1.1);
        }

        .step-icon.completed {
            background-color: #25d366;
            color: white;
            border-color: #1da750;
        }

        .step-label {
            text-align: center;
            font-weight: 600;
            color: #7a7e8c;
            margin-top: 5px;
        }

        .step-label.active {
            color: #4a6cf7;
            font-weight: 700;
        }

        .step-label.completed {
            color: #25d366;
        }

        .confirm-section {
            text-align: center;
            margin-top: 30px;
            padding-top: 30px;
            border-top: 1px dashed #e0e7ff;
        }

        .confirm-btn {
            background: linear-gradient(135deg, #25d366 0%, #1da750 100%);
            color: white;
            border: none;
            padding: 14px 40px;
            border-radius: 50px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 10px;
            box-shadow: 0 6px 20px rgba(37, 211, 102, 0.3);
        }

        .confirm-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 10px 25px rgba(37, 211, 102, 0.4);
        }

        .confirm-btn:disabled {
            background: #bdc3c7;
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .status-message {
            margin-top: 20px;
            padding: 15px;
            border-radius: 10px;
            background-color: #e8f5e9;
            color: #2e7d32;
            font-weight: 500;
            display: inline-block;
            margin-left: auto;
            margin-right: auto;
            display: block;
            text-align: center;
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            .status-flow {
                flex-direction: column;
                gap: 40px;
            }

            .status-flow::before {
                display: none;
            }

            .status-step {
                width: 100%;
                flex-direction: row;
                gap: 20px;
            }

            .step-icon {
                margin-bottom: 0;
            }

            .step-label {
                text-align: left;
                flex: 1;
            }

            .order-header {
                flex-direction: column;
                gap: 20px;
            }

            .order-status {
                width: 100%;
            }

            .top-bar {
                flex-wrap: wrap;
                gap: 15px;
                justify-content: center;
            }

            .page-title {
                position: relative;
                left: auto;
                transform: none;
                order: 2;
                width: 100%;
                text-align: center;
            }

            .back-btn {
                order: 1;
            }

            .user-info {
                order: 3;
            }
        }
    </style>
</head>
<body>
<!-- 上层：顶部导航栏 -->
<div class="top-bar">
    <!-- 返回按钮 -->
    <button class="back-btn" onclick="location.href='/clients/clientmain'">
        <i class="fas fa-arrow-left"></i> 返回主页
    </button>

    <!-- 页面标题 -->
    <div class="page-title">订单详情</div>

    <!-- 用户信息区域 -->
    <div class="user-info">
        <!-- 数据接口：后端需提供当前用户名 -->
        <span class="user-name" th:text="${user != null} ? ${user.username} : '用户名'">
                用户名
            </span>
    </div>
</div>

<!-- 下层：内容区域 -->
<div class="content-container">
    <div class="order-card">
        <!-- 订单基本信息 -->
        <div class="order-header">
            <div class="order-info">
                <!-- 数据接口：订单基本信息 -->
                <div class="info-row">
                    <div class="info-label">订单编号：</div>
                    <div class="info-value" th:text="${order != null} ? ${order.orderId} : 'OD20230623001'">OD20230623001</div>
                </div>
                <div class="info-row">
                    <div class="info-label">下单时间：</div>
                    <div class="info-value" th:text="${order != null} ? ${order.createdAt} : '2023-06-23 14:30:22'">2023-06-23 14:30:22</div>
                </div>
                <div class="info-row">
                    <div class="info-label">配送地址：</div>
                    <div class="info-value" th:text="${order != null} ? ${order.address} : '北京市海淀区中关村大街1号'">北京市海淀区中关村大街1号</div>
                </div>
            </div>

            <div class="order-status">
                <div>当前状态</div>
                <div class="status-text" th:text="${order.deliveryStatus=='pending'} ? '未接单' :(${order.deliveryStatus=='in_transit'} ? '配送中' :'已送达') ">配送中</div>
            </div>
        </div>

        <!-- 订单状态流程 -->
        <div class="status-flow">
            <!-- 步骤1：接单状态 -->
            <div class="status-step">
                <div class="step-icon"
                     th:classappend="${order.deliveryStatus!='pending'} ? 'completed':'active'">
                    <i class="fas fa-utensils"></i>
                </div>
                <div class="step-label"
                     th:classappend="${order.deliveryStatus!='pending'} ? 'completed':'active'">
                    <span th:text="${order.deliveryStatus!='pending'} ? '已接单' : '未接单'">未接单</span>
                </div>
            </div>

            <!-- 步骤2：配送状态 -->
            <div class="status-step">
                <div class="step-icon"
                     th:classappend="${order.deliveryStatus=='completed'} ? 'completed' : (${deliveryStatus=='in_transit'} ? 'active' : '')">
                    <i class="fas fa-motorcycle"></i>
                </div>
                <div class="step-label"
                     th:classappend="${order.deliveryStatus=='completed'} ? 'completed' : (${deliveryStatus=='in_transit'} ? 'active' : '')">
                    <span th:text="${order.deliveryStatus!='pending'} ? '配送中' : '未配送'">未配送</span>
                </div>
            </div>

            <!-- 步骤3：送达状态 -->
            <div class="status-step">
                <div class="step-icon"
                     th:classappend="${order.deliveryStatus=='completed'} ? 'completed' : ''">
                    <i class="fas fa-flag-checkered"></i>
                </div>
                <div class="step-label"
                     th:classappend="${order.deliveryStatus=='completed'} ? 'completed' : ''">
                    <span th:text="${order.deliveryStatus=='completed'} ? '已送达' : '未送达'">未送达</span>
                </div>
            </div>

        </div>

        <!-- 收货确认区域 -->
        <div class="confirm-section" th:if="${order.deliveryStatus != 'completed'}">
            <p style="margin-bottom: 20px; color: #7f8c8d; font-size: 16px;">
                当您收到商品后，请点击下方按钮确认收货
            </p>

            <!-- 使用表单提交方式确认收货 -->
            <form th:action="@{/clients/clientorderdetail}" method="post">
                <input type="hidden" name="orderId" th:value="${order.orderId}">
                <button type="submit" class="confirm-btn">
                    <i class="fas fa-check"></i>
                    确认收货
                </button>
            </form>
        </div>

        <div th:if="${confirmMessage}" class="status-message">
            <i class="fas fa-check-circle"></i> 收货确认成功！
        </div>
    </div>
</div>
</body>
</html>